#!/bin/bash

export ATLASTIER3CFGPUPPET=/opt/atlastier3cfg
cd $ATLASTIER3CFGPUPPET/puppet

# Checkout puppet definitions for the whole cluster
svn checkout https://atlastier3cfg.googlecode.com/svn/at3/at3moduledef/trunk at3moduledef
svn checkout https://puppetrepo.googlecode.com/svn/trunk puppetrepo 

#checkout all modules
python puppetrepo/puppetrepo.py --action co --moduledef=at3moduledef/modules.def.devel --moduledir=modules/ --modulesppfile=manifests/modules.pp --loglevel=info

cp at3moduledef/auth.conf at3moduledef/fileserver.conf ./
cp at3moduledef/site.pp manifests/

mkdir  -p $ATLASTIER3CFGPUPPET/puppetvar/run $ATLASTIER3CFGPUPPET/localpuppet $ATLASTIER3CFGPUPPET/puppet
chown -R puppet:puppet $ATLASTIER3CFGPUPPET/puppet $ATLASTIER3CFGPUPPET/puppetvar $ATLASTIER3CFGPUPPET/localpuppet
chmod  -R g+rw $ATLASTIER3CFGPUPPET/puppet $ATLASTIER3CFGPUPPET/puppetvar $ATLASTIER3CFGPUPPET/localpuppet

cp ../ks/nodes.pp manifests/nodes.pp
cp ../ks/etchosts modules/dnsmasq/templates/etchosts
cp -f ../ks/pxelinux.cfg.default modules/at3_pxe/templates/default.erb
 
